<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AdminRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
                'name' => 'required|unique:admins',
                'email'=>'required|unique:admins|email',
                'password'=>'required|string|min:6',
                'password_confirmed'=>'required|same:password',
                'role' =>'required'
            ];
    }
    public function messages(){
        return [
            'name.required' => '唯一标识必填',
            'name.unique'   => '唯一标识已存在',
            'email.required' => '帐号必填',
            'email.unique'   => '帐号已存在',
            'password.required' => '密码必填',
            'password_confirmed.required' => '确认密码必填',
            'password_confirmed.required' => '密码不一致',
            'role.required' =>'至少选择一个角色',
        ];
    }    
}